<%--
  Created by IntelliJ IDEA.
  User: Sophie
  Date: 2024/9/9
  Time: 18:24
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="<%=basePath%>/css/top.css">
    <script src="<%=basePath%>/js/jquery-3.6.3.min.js"></script>
    <script src="<%=basePath%>/js/jquery.validate.min.js"></script>
    <style>
        a{
            text-decoration: none;
        }
        .checkLogin{
            color: #6f6dff;
        }
        .checkLogin:hover{
            color: #ff1b6a;
        }
    </style>
</head>
<body>
<div class="head-wrap">
    <div class="top">
        <div class="top-left">
            <a href="">
                <img src="<%=basePath%>/img/男女混合.png" alt="">
            </a>
            <a href="UserServlet?method=mainPage">首页</a>
            <a href="ZoneServlet?method=zone">广场</a>
        </div>
        <div class="top-right">
            <c:if test="${not empty user}">
                <span>你好！<span style="color: #d34e6d;font-size: 24px">${user.name}</span></span>
                <a href="javascript:;">
                    <c:choose>
                        <c:when test="${user.avatar != null}">
                            <img src="${user.avatar}" alt="" class="avatar" width="45px" height="45px">
                        </c:when>
                        <c:otherwise>
                            <img src="<%=basePath%>/img/水豚.webp" alt="" class="avatar" width="45px">
                        </c:otherwise>
                    </c:choose>
                </a>
                <a href="UserServlet?method=logout" class="logout">注销</a>
            </c:if>
            <c:if test="${empty user}">
                <span><span style="color: #d34e6d;font-size: 24px">您还未登录，请先<a href="login.jsp" class="checkLogin">登录</a></span></span>
            </c:if>
        </div>
    </div>
</div>
</body>
<script>
    //点击top栏个人头像进入编辑个人信息页面
    $(".avatar").click(function () {
        window.location.href = "UserServlet?method=toUpdatePage&id=" +${user.id};
    })
</script>
</html>
